<template>
    <div>
<van-nav-bar
  title="订单"
  left-text="返回"
  left-arrow
  @click-left="()=>{$router.back('/')}"
/>
<p>我的订单：{{orderdata.orderId}}</p>
<p>订单时间：{{orderdata.create_time}}</p>
<p>我的订单描述：{{orderdata.product_code}}</p>
<p>我的订单价格：{{orderdata.totalPrice}}</p>
<van-submit-bar :price="orderdata.totalPrice" button-text="提交订单" @submit="onSubmit" />
    </div>

</template>

<script setup>
import { ref } from 'vue';
import { useRoute } from "vue-router";
const route=new useRoute()
import { getOrderApi } from "@/api/api";
let orderdata=ref([])
let paydata=ref({
    orderId:'',
    subject:'',
    totalPrice:0
})
getOrderApi(route.params.orderId).then(res=>{
    console.log('xq',res);
    orderdata.value=res.data.data
    paydata.value={
     orderId:res.data.data.orderId,
    subject:res.data.data.product_code,
    totalPrice:(res.data.data.totalPrice/100).toFixed(2)
    }
})
import { payApi } from "@/api/api";
const onSubmit=()=>{
payApi(paydata.value).then(res=>{
    console.log('zf',res);
    window.open(res.data.data,'_blank')
})
}

</script>

<style lang="scss" scoped>

</style>